package com.jetinno.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * Description :
 * Author :mhwang
 * Date : 2017/5/27
 * Version : V1.0
 */

public class NetWorkUtil {

    /** 判断网络是否连接
     * @param context
     * @return
     */
    public static boolean isNetworkAvailible(Context context) {
        if (context != null) {
            ConnectivityManager mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
            if(mConnectivityManager != null) {
                NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
                if (mNetworkInfo != null) {
                    return mNetworkInfo.isAvailable();
                }
            }
        }
        return false;
    }
}
